<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"/>
    <meta name="viewport"
          content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no"/>
    <meta name="format-detection" content="telephone=no, email=no"/>
    <meta name="apple-mobile-web-app-capable" content="yes"/>
    <meta name="apple-mobile-web-app-status-bar-style" content="black"/>

</head>
<body>
<script>
    var arr = [1, 100, 2, 77, 5, 3, 5, 6, 8, 6, 33];

    //sort()
    arr.sort(function (a, b) {
        return a - b;
    });


    // 冒泡排序


    function sort2(arr) {
        for (var i = 0; i < arr.length - 1; i++) {
            for (var j = 0; j < arr.length - 1 - i; j++) {
                if (arr[j] > arr[j + 1]) {
                    var str = arr[j];
                    arr[j] = arr[j + 1];
                    arr[j + 1] = str;
                }
            }
        }
    }


    //选择排序


    function sort3(arr) {
        for (var i = 0; i < arr.length - 1; i++) {
            for (var j = i + 1; j < arr.length; j++) {
                if (arr[i] > arr[j]) {
                    var str = arr[i];
                    arr[i] = arr[j];
                    arr[j] = str;
                }
            }
        }
    }


    sort3(arr);
    console.log(arr);


</script>


</body>
</html>